{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import kMeans\n",
    "import utils"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 生成随机初始点"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "datMat=np.array(utils.loadDataSet('testSet.txt'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.77724915, 2.14219912],\n",
       "       [3.24606033, 2.62601028]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kMeans.randCent(datMat, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Expect Result:  \n",
    "\n",
    "array([[1.77724915, 2.14219912],  \n",
    "       [3.24606033, 2.62601028]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.184632816681332"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kMeans.distEclud(datMat[0], datMat[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Expect Result: 5.184632816681332"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# KMeans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "datMat=np.array(utils.loadDataSet('testSet.txt'))\n",
    "myCentroids, clustAssing,_ = kMeans.kMeans(datMat,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAABHNCSVQICAgIfAhkiAAAAAlwSF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Jl0v6WMVfryRtlrSv7EH0gkCerzsk3SSp8jPK7v6wu09OffkTSVU7A+6tkp519/3u/pqkr0t6d8ljyo27T7j7E1P//Xs1AtzyckeVHzNbIWmDpK+WPZZeEMhzYmbXSRp3971lj6UEH5X0vbIHkbHlkl6c9vUBVTiwTWdmqyRdKuk/yx1Jru5UI+k6VfZAesEJQX0ws+9LOjfhW7dKukXS+mJHlK9Or9fdvzX1M7eqcVt+b5FjK4AlXKv8nZaZvV7S/ZK2uPvvyh5PHszsWkkvu/tuM1tb9nh6QSDvg7u/Pem6mb1J0vmS9pqZ1CgzPGFmb3X3lwocYqbavd4mM/uIpGslrfPqLVA4IGnltK9XSDpY0lgKYWbz1Qji97r7A2WPJ0dXSLrOzN4laVDSG83sa+7+oZLHlRoLggpgZs9LGnb3kHdV64uZXSPpi5KudPdDZY8na2Y2T41J3HWSxiX9VNLfuPtTpQ4sJ9bIQO6R9Ft331L2eIoylZF/wt2vLXss3aBGjqx8WdIbJD1iZj8zs38pe0BZmprI/bikh9SY+LuvqkF8yhWSPizpqqn382dTGSsCREYOAJEjIweAyBHIASByBHIAiByBHAAiRyAHgMgRyAEgcgRyAIjc/wNNqWsmjODiDAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "utils.plotKMeans(datMat, 4, myCentroids, clustAssing)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# BiKmeans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the center is far from every one\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF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XtMRTCza83sOTN73sx2xR5P0cxswMx+YmbPmNnTZjYWe0wxmFmPmR0ws4dij6URgrwJMxuQ9F5Jv4s9lkgelXS5uw9J+rWk3ZHH03Fm1iPpq5LeJ+kySR80s8vijqpwZyR92t3fLukqSR8r4WcgSWOSnok9iGYI8ubukvQZSaVcFXb3R9z9zNyXP5O0IeZ4CnKlpOfdfcbdX5H0bUk3RB5Todz9iLvvn/vPL6sSZqU6pN3MNkgalfT12GNphiBvwMyulzTr7r+MPZZEfFTSD2MPogDrJb2w4OvDKlmILWRmg5I2S/p53JEU7kuqTOJejT2QZkr/hCAz+5Gk/hrful3SZyWNFDui4jX6DNz9wbnX3K7Kn9v3Fjm2SKzGtVL+RWZmr5P0XUmfcPf/iz2eopjZDkm/d/d9ZrYt9niaKX2Qu/t7al03syskXSLpl2YmVUoK+83sSnc/WuAQO67eZzDPzG6RtEPSdi/HxoPDkgYWfL1B0ouRxhKNma1QJcTvdff7Y4+nYFslXW9m/yBppaQ3mNm33P3DkcdVExuCWmRmhyQNu3sqp6AVwsyulfRFSe9292Oxx1MEM1uuysLudkmzkn4h6UPu/nTUgRXIKrOXeyT9r7t/IvZ4Ypqbkd/q7jtij6UeauRo5iuSXi/pUTN70sy+FntAnTa3uPtxSQ+rssi3t0whPmerpJslXT33v/uTc7NTJIgZOQBkjhk5AGSOIAeAzBHkAJA5ghwAMkeQA0DmCHIAyBxBDgCZ+3/4e+uaxBZ02gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "datMat3=np.array(utils.loadDataSet('testSet2.txt'))\n",
    "centList,myNewAssments=kMeans.biKmeans(datMat3,3)\n",
    "utils.plotKMeans(datMat3, 3, np.array(centList), myNewAssments)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([-0.45965615, -2.7782156 ]),\n",
       " array([-2.94737575,  3.3263781 ]),\n",
       " array([2.93386365, 3.12782785])]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "centList"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Expect Result:  \n",
    "\n",
    "[array([-0.45965615, -2.7782156 ]),  \n",
    " array([-2.94737575,  3.3263781 ]),  \n",
    " array([2.93386365, 3.12782785])]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 10.4.1的例子中的网页访问不了"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
